/**
	Pulsar engine. Additional include file.
	Additional windows events

	Copyright (C) 2013-2014 Dmitry Dolgov

	This program is free software; you can redistribute it and/or modify it under the terms of the
	GNU General Public License as published by the Free Software Foundation; either version 2 of
	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
	without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
	See the GNU General Public License for more details.
*/

#if !defined(PL_WINDOWS) && !defined(PL_WINDOWS64)
#error "Wrong Operation System"
#endif

namespace pl
{

#define DECLARE_ON_WINDOW_MSG() virtual bool onWindowMsg(pl::WndMessage& msg)
#define DECLARE_ON_MSG_LOOP() virtual bool onMsgLoop(pl::WndLoopData& pMsg)

/*
	Windows from main message
*/
struct WndMessage
{
public:
	WndMessage() :
	bPassToDefWindowProc(true),
	retCode(0)
	{
	}

	/// Window handle
	HWND hWindow;
	/// Window message WM_***
	UINT msg;
	/// wParam
	WPARAM wParam;
	/// lParam
	LPARAM lParam;
	/// Use DefWindowProc() to handle a message
	bool bPassToDefWindowProc;
	/// use whem bPassToDefWindowProc == false
	LONG retCode;
};

/*
	Messages form main window loop
*/
struct WndLoopData
{
	/// GetMessage() / PeekMessage() structure
	::MSG msg;
};

/*
	IWindowMsg event collection
*/
class IWindowMsg : public ListNode<IWindowMsg>
{
public:
	DECLARE_ON_WINDOW_MSG()
	{
		return true;
	}
	DECLARE_ON_MSG_LOOP()
	{
		return false;
	}

	/// Send messages from main window
	static bool callOnWindowMsg(WndMessage& msg);
	/// Send messages from main loop
	static bool callOnMsgLoop(WndLoopData& pMsg);

protected:
	/// Ctor
	IWindowMsg();

private:
	static List<IWindowMsg> _windowMsgGroup;
};

} // namespace pl

//
// End of file 'pulsar_events_win.h'
//
